.mr-state-widget
  = render 'projects/merge_requests/widget/heading'
  .mr-widget-body
    %h4
      已合并
      - if @merge_request.merge_event
        提交者：#{link_to_member(@project, @merge_request.merge_event.author, avatar: true)}
        #{time_ago_with_tooltip(@merge_request.merge_event.created_at)}
    %div
      - if !@merge_request.source_branch_exists? || (params[:delete_source] == 'true')
        %p
          此变更已合并到
          #{link_to @merge_request.target_branch, namespace_project_commits_path(@project.namespace, @project, @merge_request.target_branch), class: "label-branch"}，
          来源分支已被删除。
        = render 'projects/merge_requests/widget/merged_buttons'
      - elsif @merge_request.can_remove_source_branch?(current_user)
        .remove_source_branch_widget
          %p
            此变更已合并到
            #{link_to @merge_request.target_branch, namespace_project_commits_path(@project.namespace, @project, @merge_request.target_branch), class: "label-branch"}，
            你现在可以删除来源分支。
          = render 'projects/merge_requests/widget/merged_buttons', source_branch_exists: true
        .remove_source_branch_widget.failed.hide
          %p
            删除来源分支 '#{@merge_request.source_branch}' 失败。

        .remove_source_branch_in_progress.hide
          %p
            = icon('spinner spin')
            正在删除来源分支 '#{@merge_request.source_branch}'。请稍候，页面将会被自动重载。

        :javascript
          $('.remove_source_branch').on('click', function() {
            $('.remove_source_branch_widget').hide();
            $('.remove_source_branch_in_progress').show();
          });

          $(".remove_source_branch").on("ajax:success", function (e, data, status, xhr) {
            location.reload();
          });

          $(".remove_source_branch").on("ajax:error", function (e, data, status, xhr) {
            $('.remove_source_branch_widget').hide();
            $('.remove_source_branch_in_progress').hide();
            $('.remove_source_branch_widget.failed').show();
          });
      - else
        %p
          此变更已合并到
          #{link_to @merge_request.target_branch, namespace_project_commits_path(@project.namespace, @project, @merge_request.target_branch), class: "label-branch"}。
        = render 'projects/merge_requests/widget/merged_buttons'
